package com.itheima.service.impl;

import com.itheima.dao.ActRuExecutionDao;
import com.itheima.pojo.ActRuExecution;
import com.itheima.service.ActRuExecutionService;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * (ActRuExecution)表服务实现类
 *
 * @author makejava
 * @since 2022-01-16 15:48:51
 */
@Service("actRuExecutionService")
public class ActRuExecutionServiceImpl implements ActRuExecutionService {
    @Resource
    private ActRuExecutionDao actRuExecutionDao;

    /**
     * 通过ID查询单条数据
     *
     * @param id_ 主键
     * @return 实例对象
     */
    @Override
    public ActRuExecution queryById(String id_) {
        return this.actRuExecutionDao.queryById(id_);
    }

    /**
     * 分页查询
     *
     * @param actRuExecution 筛选条件
     * @param pageRequest      分页对象
     * @return 查询结果
     */
    @Override
    public Page<ActRuExecution> queryByPage(ActRuExecution actRuExecution, PageRequest pageRequest) {
        long total = this.actRuExecutionDao.count(actRuExecution);
        return new PageImpl<>(this.actRuExecutionDao.queryAllByLimit(actRuExecution, pageRequest), pageRequest, total);
    }

    /**
     * 新增数据
     *
     * @param actRuExecution 实例对象
     * @return 实例对象
     */
    @Override
    public ActRuExecution insert(ActRuExecution actRuExecution) {
        this.actRuExecutionDao.insert(actRuExecution);
        return actRuExecution;
    }

    /**
     * 修改数据
     *
     * @param actRuExecution 实例对象
     * @return 实例对象
     */
    @Override
    public ActRuExecution update(ActRuExecution actRuExecution) {
        this.actRuExecutionDao.update(actRuExecution);
        return this.queryById(actRuExecution.getId_());
    }

    /**
     * 通过主键删除数据
     *
     * @param id_ 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(String id_) {
        return this.actRuExecutionDao.deleteById(id_) > 0;
    }
}
